package com.idheima.lianxi;

import java.util.ArrayList;

public class Studentshixian1 implements Studentcaozuo {

    @Override
    public void print(ArrayList<Student> students) {

        System.out.println("==全班全部学生信息如下====");
        int nan=0;
        int nv=0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println("姓名：" + student.getName() + "  性别：" + student.getSex() + "  成绩：" + student.getScore());
            if(student.getSex()=='男'){
                nan++;
            }else{
                nv++;
            }
        }
        System.out.println("全班共有"+nan+"个男生，"+nv+"个女生");
        System.out.println("全班总人数："+students.size());
        System.out.println("==========================");
    }

    @Override
    public void Evaluation(ArrayList<Student> students) {
        double score=0.0;
        double max =students.get(0).getScore();
        double min =students.get(0).getScore();
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            if (student.getScore()>max){
                max=student.getScore();
            }
            if (student.getScore()<min){
                min=student.getScore();
            }
            score+=student.getScore();
        }
        System.out.println("全班最高成绩为："+max);
        System.out.println("全班最低成绩为："+min);
        System.out.println("全班平均成绩为："+(score-max-min)/(students.size()-2));
    }
}
